package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.beans.dto.LumierePayMemberDto;
import org.linlinjava.litemall.admin.service.AdminLumierePayMemberService;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 付费会员
 *
 * @author yliyun
 * @date 2022/09/14
 */
@Api(tags = "付费会员API")
@RestController
@RequestMapping("/admin/payMember")
@Validated
public class AdminLumierePayMemberController {
    /**
     * 卢米埃支付会员服务
     */
    @Autowired
    private AdminLumierePayMemberService lumierePayMemberService;

    /**
     * 列表
     * 查询付费会员种类
     *
     * @param payMemberName 支付成员名
     * @param page          页面
     * @param limit         限制
     * @param sort          排序
     * @param order         订单
     * @return {@link Object}
     */
    @ApiOperation("查询付费会员列表")
    @GetMapping("list")
    @LogAnno
    public Object list(String payMemberName,String startTimeStartDate,
                       String startTimeEndDate,String endTimeStartDate, String endTimeEndDate,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       @Sort @RequestParam(defaultValue = "add_time") String sort,
                       @Order @RequestParam(defaultValue = "asc") String order){
        return lumierePayMemberService.listNew(payMemberName,startTimeStartDate,startTimeEndDate,endTimeStartDate,endTimeEndDate,page,limit,sort,order);
    }

    /**
     * 添加付费会员
     *
     * @param dto dto
     * @return {@link Object}
     */
    @ApiOperation("添加付费会员")
    @PutMapping("add")
    @LogAnno
    public Object add(@RequestBody LumierePayMemberDto dto){
        return lumierePayMemberService.add(dto);
    }

    /**
     * 会员详情
     *
     * @param memberId 成员身份
     * @return {@link Object}
     */
    @ApiOperation("付费会员详情")
    @GetMapping("detail")
    @LogAnno
    public Object detail(@RequestParam Integer memberId){
        return  lumierePayMemberService.detail(memberId);
    }

    /**
     * 更新
     * 更改付费会员
     *
     * @param dto dto
     * @return {@link Object}
     */
    @ApiOperation("更新付费会员")
    @PutMapping("update")
    @LogAnno
    public Object update(@RequestBody LumierePayMemberDto dto){
        return lumierePayMemberService.update(dto);
    }

    /**
     * 更新状态
     * 更改付费会员状态
     *
     * @param memberId 成员身份
     * @return {@link Object}
     */
    @ApiOperation("更改付费会员状态")
    @PutMapping("updateStatus")
    @LogAnno
    public Object updateStatus(@RequestParam Integer memberId){

        return lumierePayMemberService.updateStatus(memberId);
    }

    /**
     * 删除
     *
     * @param memberId 成员身份
     * @return {@link Object}
     */
    @ApiOperation("删除付费会员")
    @DeleteMapping("delete")
    @LogAnno
    public Object delete(@RequestParam Integer memberId){
           return lumierePayMemberService.delete(memberId);
    }







}
